﻿using Autofac;
using DJY.Code;
using DJY.Domain.Entity.SystemSecurity;
using DJY.Domain.IRepository.SystemSecurity;
using DJY.Service.SystemSecurity;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.Entity;
using System.Data.SqlClient;
using System.Linq;

namespace DJY.Application.SystemSecurity
{
    public class SysLogService : ISysLogService
    {
        /// <summary>
        /// 插入日志
        /// </summary>
        /// <param name="log">日志</param>
        public int InsertLog(SysLogEntity log)
        {
            using (var scope = OperatorProvider.BeginLifetimeScope(null))
            {
                using (var db = scope.Resolve<DbContext>())
                {
                    ISysLogRepository repos = OperatorProvider.Resolve<ISysLogRepository>();
                    return repos.Insert(db, log);
                }
            }
        }

        /// <summary>
        /// 插入日志
        /// </summary>
        /// <param name="logs">日志列表</param>
        public int InsertLog(List<SysLogEntity> logs)
        {
            using (var scope = OperatorProvider.BeginLifetimeScope(null))
            {
                using (var db = scope.Resolve<DbContext>())
                {
                    ISysLogRepository repos = OperatorProvider.Resolve<ISysLogRepository>();
                    return repos.Insert(db, logs);
                }
            }
        }
    }
}
